package com.htjc.uep.center.basic.service;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Component;


@Component
public class CenterBasicWork extends Thread{

	private static Logger log = LoggerFactory.getLogger(CenterBasicWork.class);
	
	@Resource(name = "taskExecutor")
	private TaskExecutor taskExecutor;
	
	private static final Map<String, Object> workBeanMap = new HashMap<String, Object>();
	
	static
	{
		log.info("**********************************************************************************");
		log.info("****   积分中心基础服务启动成功, 全量最新版本={}  ****", "20181102.001");
		log.info("**********************************************************************************");
	}
	
	/**
	 * 初始化待生成线程内存列表
	 * @since 0.1
	 */
	public void initBeanMap()
	{
		workBeanMap.put("", "");
	}
	
	public void execute(String workType)
	{
		if (workBeanMap.isEmpty())
		{
			initBeanMap();
		}
		this.taskExecutor.execute(new AcctThread(workType));
	}
	
	private class AcctThread implements Runnable
	{
		private String workType;
		
		private AcctThread(String workType) 
		{
			this.workType = workType;
		}
		
		@Override
		public void run() 
		{
			try 
			{
				@SuppressWarnings("unused")
				Object obj = workBeanMap.get(this.workType);
			}
			catch (Exception e) 
			{
				log.error("线程创建错误", e);
				e.printStackTrace();
			}
		}
	}
}




























